package content.views;
import feffects.easing.Quad;
import js.Lib;
import params.GlobalParams;
import tools.ASprite;

/**
 * ...
 * @author PRASS
 */

class About extends BaseView
{
	private var _container 	: ASprite;
	private var _title		: ASprite;
	private var _about		: ASprite;
	private var _desc		: ASprite;
	private var _parts		: ASprite;
	private var _isaacPic	: ASprite;
	
	public function new( id : String, tpl : String ) 
	{
		super(id,tpl);

		dom.css("background-image", "url(" + GlobalParams.BG_ABOUT + ")");
	}
	
	override public function build():Void 
	{
		_container = new ASprite( new JQuery("#containerAbout") );
		_container.setX(356);
		
		_parts = new ASprite( new JQuery(".part"));
		_parts.setAlpha(0);
		
		_desc = new ASprite( new JQuery("#desc") );
		_desc.setHeight(0);
		
		_isaacPic = new ASprite( new JQuery("#isaac img") );
		_isaacPic.setAlpha(0);
		
		_title = new ASprite( new JQuery("#aboutTitle"));
		_title.setAlpha(0);
	}
	
	override public function play():Void 
	{
		super.play();
		
		_parts.tween(0, _parts.setAlpha, 1, 600, Quad.easeInOut,null,450);
		_desc.tween(0, _desc.setHeight, 500, 600, Quad.easeInOut);
		_isaacPic.tween(0, _isaacPic.setAlpha, 1, 800, Quad.easeInOut,null,800);
		_title.tween(0, _title.setAlpha, 1, 400, Quad.easeInOut);
	}
	
	override public function hide():Void 
	{
		_parts.tween(1, _parts.setAlpha, 0, 200, Quad.easeInOut);
		_desc.tween(500, _desc.setHeight, 0, 500, Quad.easeOut,null,150);
		_isaacPic.tween(_isaacPic.getAlpha(), _isaacPic.setAlpha, 0, 200, Quad.easeInOut);
		_title.tween(_title.getAlpha(), _title.setAlpha, 0, 400, Quad.easeInOut);
	}
	
	override public function resize(_w:Int, _h:Int):Void 
	{
		super.resize(_w, _h);
		
		if (_container == null || _title == null) return;
		
		_container.setY(145);
		
		var _currentX : Int;
		
		if ( _w < 1100)
			_currentX	=  cast ( Math.max(  ( _w + 216 -  720 ) * .5, 216) );
		else
			_currentX	=  356;
			
		_container.setX( _currentX );
		_title.setX( _currentX );
		_title.setY( 95);
	}
	
	
}